#ifndef AUDIO_H
#define AUDIO_H

#include "IAudio.h"

#include <SDL.h>
#include <string>
using namespace std;
class CSound;

#define MAX_LOADED_SOUNDS 15

//!Audio class  to handle sounds.
class CAudio: public IAudio
{
private:

	//!Audio specifications
	SDL_AudioSpec* m_audioSpec;

	//!Volume of the sound
	static int m_volume;

	//!Number of sound which are loaded
	int m_numberOfSoundLoaded;

	//!Array of sound
	CSound* m_arrayOfSound[MAX_LOADED_SOUNDS];
	

public:

	//!Constructor
	CAudio(void);

	//!Destructor
	~CAudio(void);

	//!Initialise the Audio component.
	bool init(void);

	//!Load a sound .wav.
	/*!
	\param idSound Index of the sound.
	\param path Path of the sound file.
	\return True if the sound was loaded. False if it failed.
	*/
	bool loadSound(int* idSound, string path);

	//!Player a sound.
	/*!
	\param indexSound index of the sound to play.
	\return -1 if failed or 0 in other case.
	*/
	int playSound(int indexSound);

	//!Stops all the sounds that are currently played.
	void clearPlayingSounds(void);

	//!Audio callback
	static void audioCallback(void *user_data, Uint8 *audio, int length);

	//!Set the volume
	/*!
	\param volume New volume.
	*/
	void setVolume(int volume);

	//!Get the volume.
	/*!
	\return Return the volume of the sound.
	*/
	int getVolume(void)const;
};

#endif
